home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / msqc25t1 / avldrvs.c < prev    next >
C/C++ Source or Header  |  1990-09-03  |  899b  |  39 lines

  1.  
  2. /* AVLDRVS.C illustrates drive functions including:
  3.  *      _getdrive       _chdrive        _getdcwd
  4.  *
  5.  * See DIRECT.C for an example of getcwd.
  6.  *
  7.  *  Modify by Tom Harrold 9/90
  8.  *
  9.  *  This program will print the available drives on the screen. No user
  10.  *  interaction required. Just run it!
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <direct.h>
  15. #include <stdlib.h>
  16. #include <conio.h>
  17.  
  18. void main()
  19. {
  20.     int drive, curdrive;
  21.     static char path[_MAX_PATH];
  22.  
  23.     /* Save current drive. */
  24.     curdrive = _getdrive();
  25.  
  26.     printf( "Available drives are: \n" );
  27.  
  28. /* If we can switch to the drive, it exists. */
  29.     for( drive = 1; drive <= 26; drive++ )
  30.         if( !_chdrive( drive ) )
  31.             printf( "%c: ", drive + 'A' - 1 );
  32.  
  33.     /* Restore original drive. This is only necessary for DOS. Under OS/2,
  34.      * the current drive of the calling process is always restored.
  35.      */
  36.     _chdrive( curdrive );
  37. }
  38.  
  39.